using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsPhoneGame1.Shapes;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using WindowsPhoneGame1.Collisions;

namespace WindowsPhoneGame1.LevelItems
{
    public abstract class LevelItem
    {
        public static readonly Vector2 VIEW_OFFSET = new Vector2(200, -100);

        public WindowsPhoneGame1.Shapes.PointF Position { get; set; }
        protected Shape collisionShape;
        protected Texture2D texture;

        public Shape CollisionShape
        {
            get { return collisionShape; }
            protected set { collisionShape = value;}
        }

        protected LevelItem(Shapes.PointF position, Shape collisionShape, Texture2D texture)
        {
            Position = position;
            CollisionShape = collisionShape;
            this.texture = texture;
        }

        public Collision CollidesWith(LevelItem other)
        {
            return new Collision(this, other);
        }

        public virtual void Draw(GameTime gameTime, PointF position, Game1 game)
        {
            game.SpriteBatch.Draw(
                texture,
                new Vector2(
                    Position.X - position.X,
                    game.GraphicsDevice.Viewport.Height - CollisionShape.Bounds.Height
                ) + VIEW_OFFSET,
                Color.White
            ); 
        }

        public Texture2D Texture
        {
            get { return texture; }
        }
    }
}
